package com.hgyc.mom.mes.service.impl;

import com.hgyc.mom.mes.vo.SopDocumentVO;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hgyc.mom.mes.mapper.SopDocumentMapper;
import com.hgyc.mom.mes.entity.SopDocument;
import com.hgyc.mom.mes.service.SopDocumentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import com.hgyc.mom.common.exception.BizException;
import org.springframework.util.CollectionUtils;

/**
 * 文档管理Service业务层实现
 *
 * @author fwj
 * @since 2025-06-18
 */
@Slf4j
@Service
public class SopDocumentServiceImpl extends ServiceImpl<SopDocumentMapper, SopDocument> implements SopDocumentService {

    @Override
    public List<SopDocument> getByParentId(Long parentId) {
        LambdaQueryWrapper<SopDocument> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SopDocument::getManageId, parentId);
        return list(wrapper);
    }

    @Override
    public void deleteByParentId(Long parentId) {
        LambdaQueryWrapper<SopDocument> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SopDocument::getManageId, parentId);
        remove(wrapper);
    }

    @Override
    public void deleteBatchByParentIds(List<Long> parentIds) {
        LambdaQueryWrapper<SopDocument> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SopDocument::getManageId, parentIds);
        remove(wrapper);
    }

    @Override
    public List<SopDocumentVO> getDocumentByProduct(Long materialId) {
        return baseMapper.getDocumentByProduct(materialId);
    }
}